#include "ZigbusAddressingType.h"

ZigbusAddressingType::ZigbusAddressingType()
    : ZigbusItem(-1, ADDRESSING_TYPE_SIZE)
{
}

ZigbusAddressingType::ZigbusAddressingType(int value)
    : ZigbusItem(value, ADDRESSING_TYPE_SIZE)
{
}

ZigbusAddressingType::ZigbusAddressingType(const QString &str)
    : ZigbusItem(-1, ADDRESSING_TYPE_SIZE)
{
    if(str == "direct") setValue(ADDR_TYPE_DIRECT);
    else if(str == "group") setValue(ADDR_TYPE_GROUP);
}

ZigbusAddressingType::ZigbusAddressingType(const ZigbusAddressingType &other)
    : ZigbusItem(other)
{
}

QString ZigbusAddressingType::text() const
{
    switch(getValue()) {
    case ADDR_TYPE_DIRECT: return "direct";
    case ADDR_TYPE_GROUP: return "group";
    default: return "invalid";
    }
}
